<template>
	<view class='pt'>
		<view class="header dFlex jBetween_aCenter" :style="{
			'height':headerHeight+'px',
			'padding-top':headerTop+'px'
		}">
			<view class="backIcon imgPublic" @tap='back()'>
				<image src="../static/images/back.png" mode="widthFix"></image>
			</view>
			<view class='header_title'>洗匣士拼好团</view>
			<view class="backIcon"></view>
		</view>
		<view class='list'>
			<view class="ptOne dFlex jStart_aStart" v-for="(item,index) in list" :key='index' @tap='lookDetail(item.productId)'>
				<view class="ptImg imgPublic">
					<image :src="item.list_img" mode="widthFix"></image>
				</view>
				<view class="ptInfo">
					<view class='shopName'>{{item.product_name}}</view>
					<view class="shopPrice">
						<view class="price">￥<text>{{item.sell_price}}元/{{item.specs_name}}</text></view>
						<view class="btns dFlex jStart_aCenter">
							<view class='btn' @click.stop='lookNearPt(item.productId)'>附近的拼单</view>
							<view class='btn'>发起拼单</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="kefu imgPublic" @click="lookOrder">
			<image src="https://wx.gdxixiashi.com/public/images/person/tuan.png" mode="widthFix"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				headerTop:'40',
				headerHeight:'50',
				page:1,
				load:false,
				list:[],
			};
		},
		onLoad(){
			// #ifdef MP-WEIXIN
			this.headerTop = uni.getMenuButtonBoundingClientRect().top;
			this.headerHeight = uni.getMenuButtonBoundingClientRect().height;
			// #endif
			
			this.initShop();
		},
		onReachBottom() {
			if(this.load){
				this.load = false;
				this.page++;
				this.initData();
			}
		},
		methods:{
			// 查看拼团订单
			lookOrder(){
				if(uni.getStorageSync('userId')){
					uni.navigateTo({
						url:'/person/orders_pt'
					})
				}else{
					uni.redirectTo({
						url:'/person/login'
					})
				}
			},
			initShop(){
				this.tool.getData('Product/goodsList',{
					page:this.page,
					type:'2',
				}).then(res=>{
					if(res){
						this.list = this.page == 1?res.list:this.list.concat(res.list);
						this.load = res.list.length>=10?true:false;
					}
				}).catch(err=>{
					console.log(err);
				})
			},
			// 商品详情
			lookDetail(productId){
				uni.navigateTo({
					url:"/kind/shopDetail?productId="+productId,
				})
			},
			// 查看附近拼团
			lookNearPt(productId){
				uni.navigateTo({
					url:'./nearPT?productId='+productId,
				})
			},
			back(){
				uni.navigateBack({
					delta:1
				})
			}
		}
	}
</script>

<style lang="scss">
	.pt{
		width:100%;
		.kefu{
			width: 50px;
			height: 50px;
			position: fixed;
			right: 10px;
			bottom: 90px;
			border:1px solid rgba(0,0,0,0.2);
			padding:10px;
			box-sizing: border-box;
			border-radius: 50%;
			background:white;
		}
		.list{
			.ptOne{
				.ptInfo{
					width:calc(100% - 100px);
					.btns{
						flex:1;
						.btn{
							width: auto;
							background:#5c9ff8;
							color: white;
							padding:3px 8px;
							border-radius: 5px;
							font-size:12px;
							margin-left: 5px;
						}
					}
					.shopPrice{
						.price{
							color:#5c9ff8;
							font-size:12px;
							margin:5px 0 ;
							text{
								font-size:15px;
							}
						}
						width:100%;
					}
					.shopName{
						width:100%;
						word-break: break-all;
						overflow: hidden;
						display: -webkit-box;
						-webkit-line-clamp: 2;
						-webkit-box-orient: vertical;
					}
				}
				.ptImg{
					width:90px;
					height:90px;
					overflow: hidden;
					margin-right:10px;
					image{
						border-radius: 4px;
					}
				}
				width:100%;
				background: white;
				padding:10px;
				box-sizing: border-box;
				margin-bottom:12px;
				border-radius: 4px;
			}
			width:100%;
			padding:12px;
			box-sizing: border-box;
		}
		.header{
			width:calc(100% - 24px);
			padding-left:12px;
			padding-right:12px;
			padding-bottom:5px;
			background:#5c9ff8;
			.backIcon{
				width:20px;
				height: 20px;
				padding:2px;
				box-sizing: border-box;
				border: 1px solid white;
				border-radius: 50%;
			}
			.header_title{
				font-size:16px;
				color: white;
				// background-image: linear-gradient(to bottom,#8abff1,#ffffff);
				// background-clip: text;
				// -webkit-background-clip: text;
				// -webkit-text-fill-color: transparent;
				font-weight: bold;
			}
		}
	}
</style>
